package training.irpf;

import java.math.BigDecimal;

public class IRPF {

	private static BigDecimal tax1 = new BigDecimal("7.5");
	private static BigDecimal deducao1 = new BigDecimal("1409.95");
	private static BigDecimal tax2 = new BigDecimal("15.0");
	private static BigDecimal deducao2 = new BigDecimal("3523.01");
	private static BigDecimal tax3 = new BigDecimal("22.5");
	private static BigDecimal deducao3 = new BigDecimal("6340.47");
	private static BigDecimal tax4 = new BigDecimal("27.5");
	private static BigDecimal deducao4 = new BigDecimal("8687.45");

	public static BigDecimal calculatesTax(BigDecimal baseAnual) {
		BigDecimal ret = new BigDecimal("0");

		if (baseAnual.compareTo(new BigDecimal("46939.56")) == 1){
			ret = baseAnual.multiply(tax4).divide(new BigDecimal("100")).subtract(deducao4);
		}else if(baseAnual.compareTo(new BigDecimal("37566.12")) == 1){
			ret = baseAnual.multiply(tax3).divide(new BigDecimal("100")).subtract(deducao3);
		}else if (baseAnual.compareTo(new BigDecimal("28174.20")) == 1){
			
			ret = baseAnual.multiply(tax2).divide(new BigDecimal("100")).subtract(deducao2);
		}else if (baseAnual.compareTo(new BigDecimal("18799.32")) == 1){
			ret = baseAnual.multiply(tax1).divide(new BigDecimal("100")).subtract(deducao1);
		}
		System.out.println(ret.toString());
		return ret;
	}

}
